define(function(require, exports, module){
	require("resource/js/easyui/themes/icon.css");
	require("resource/js/easyui/easyloader.js");
	var CONT = require("oa/act/js/actcont.js");
	var EasyUtil = require("resource/js/component/easyutil.js");
	var urltool = require("resource/js/component/urlTool.js");
	exports.init = function(){
		var data = JSON.parse(window.sessionStorage.ACT_DATAGRID_DATA);
		//封装表格列 数据
		var columnsList =[];
		var widthLen = 100;
		for(var k in data.cols){ 
			var hFlag =false;
			if (data.cols[k].showtype==CONT.showType.FORM_SHOWTYPE_HIDDEN){
				widthLen=70;
				hFlag=true;
			}else if(data.cols[k].showtype==CONT.showType.FORM_SHOWTYPE_TEXTAREA){
				widthLen=200;
			}else if(data.cols[k].showtype==CONT.showType.FORM_SHOWTYPE_INTEGER||data.cols[k].showtype==CONT.showType.FORM_SHOWTYPE_NUMBER){
				widthLen =50
			}else{
				widthLen = 70;
			}
			var formatter = function(value,row,index){
				if(!value){
					value = "";
				}
				return "<span title='"+value+"'><xmp>"+value+"</xmp></span>";
			}
			var colfiled =  {field:data.cols[k].colname,title:data.cols[k].colnamech,align:'center',width:widthLen,hidden:hFlag,formatter:formatter,styler : function(value, row, index){
				if(k > 0){
					return 'border-left:1px dotted #d7e6fb;';  
				}
            }};
			columnsList.push(colfiled);
		}
		using(["datagrid","panel","parser"],function(){
			var dg = null;
			var total = data.data.length;
			var size = 10;

			var config={
					fit:true,
					columns:[columnsList],
					fitColumns:true,
					singleSelect:false,
					striped:true,
					autoRowHeight:true,
					resizeHandle:true,
					nowrap:true,
					rownumbers:true,
					pageSize:size,
					pageList:[size],
					pagination:true,
					data:data.data.slice(0,size), 
					toolbar:{ 
						title:{
							_class:"",
							text:data.tab.tablename
						},
						btn:[]
					}
				};
			
			$('#dataGrid').css('width','80%');
			$('#dataGrid').css('height','70%');
			$('#dataGrid').css('margin-top',0-$('#dataGrid').innerHeight()/2);
			$('#dataGrid').css('margin-left',0-$('#dataGrid').innerWidth()/2);
			dg =$('table').datagrid(config);
			//分页
			var pager = dg.datagrid("getPager");  
            pager.pagination({  
                total:total,  
                onSelectPage:function (pageNo, pageSize) {  
                    var start = (pageNo - 1) * pageSize;  
                    var end = start + pageSize;  
                    dg.datagrid("loadData", data.data.slice(start, end));  
                    pager.pagination('refresh', {  
                        total:total,  
                        pageNumber:pageNo  
                    });  
                }  
            });  
           
		});
	};
});
